// 题目链接：https://www.luogu.com.cn/problem/P1678
#include <iostream>
#include <algorithm>

using namespace std;

const int M = 100010;
const int N = 100010;
int m, n;
int a[M];
int b[N];

int binary_search(int x)
{
    int l = -1;
    int r = m;
    int mid;
    while (l + 1 < r)
    {
        mid = (l + r) / 2;
        if (a[mid] <= x)
            l = mid;
        else
            r = mid;
    }
    if (l == -1)
        return a[r] - x;
    else if (r == m)
        return x - a[l];
    else
        return min(x - a[l], a[r] - x);
}

int main()
{
    scanf("%d %d", &m, &n);
    for (int i = 0; i < m; ++i)
    {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &b[i]);
    }

    sort(a, a + m);

    long long cnt = 0;
    for (int i = 0; i < n; ++i)
    {
        cnt += binary_search(b[i]);
    }
    printf("%lld", cnt);

    return 0;
}